
// #include "complib/include/comp_api.h"
#include "net_init/net_init.h"

#include "learn_mac/learn_mac_cfg.h"
#include "static_mac/static_mac_cfg.h"

void create_debug_file()
{
	FILE *fp;
	char str[] = "****** debug message ******\n";
	fp = fopen("debug_log.txt", "w");
	fwrite(str, sizeof(char), strlen(str), fp);
	fclose(fp);
	return;
}

int main(int argc, char *argv[])
{
	setbuf(stdout, NULL);

	int ret = 0;

	u16 ltswitch_mid = 0;
	// 初始化进程
	char test_rule[64] = {0};
	char temp_net_interface[16] = {0};

	u32 sw_version = 0x20240224;

	if (argc != 2)
	{
		printf("input format:./l2switch net_interface\n");
		return 0;
	}

	// libpcap initialization
	sprintf(temp_net_interface, "%s", argv[1]);

	create_debug_file();

	// 进入网络初始化状态
	ret = net_init(temp_net_interface, &ltswitch_mid, sw_version);
	if (ret == -1)
	{
		printf("net_init fail\n");
		return 0;
	}

	// 进入静态MAC配置阶段
	ret = static_mac_cfg();
	if (ret == -1)
	{
		printf("static_mac_cfg fail\n");
		return 0;
	}

#if 0
	//进入mac自学习配置阶段
	ret = learn_mac_cfg();
	if(ret == -1)
	{
		printf("learn_mac_cfg fail\n");
		return 0;
	}
#endif

	resource_clear(temp_net_interface);

	return 0;
}
